import java.util.Arrays;

public class Text {
    public static void main(String[] args) {
        int[] nums1 = {1,2,3,0,0,0};
        int[] nums2 = {2,5,6};
        int m = 6; int n = 3;
        Arrays.sort(nums1);
        Arrays.sort(nums2);
        int max = Math.max(m, n);
        int[] arr = new int[n+m];
        int a = 0; int b = 0;
        for (int i = 0; i < n+m; i++) {
            if(nums1[a]>nums2[b]){
                arr[i] = nums2[b];
                b++;
            }else{
                arr[i] = nums1[a];
                a++;
            }
            if(a==m){
                for (int j = b; j < n; j++) {
                    i++;
                    arr[i] = nums2[j];
                }
                break;
            }
            if(b==n){
                for (int j = a; j < m; j++) {
                    i++;
                    arr[i] = nums1[j];
                }
                break;
            }
        }

    }
}
